package org.rc.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.rc.entity.RoleMenu;
import org.rc.mapper.RoleMenuMapper;
import org.rc.service.RoleMenuService;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleMenuServiceImpl extends ServiceImpl<RoleMenuMapper, RoleMenu> implements RoleMenuService {

    @Override
    public List<RoleMenu> getByRoleId(Long roleId) {
        QueryWrapper<RoleMenu> qw = new QueryWrapper<>();
        qw.eq("role_id",roleId);
        return this.list(qw);
    }

    @Override
    public List<RoleMenu> getByRoleIds(List<Long> roles) {
        QueryWrapper<RoleMenu> qw = new QueryWrapper<>();
        qw.in("role_id",roles);
        return this.list(qw);
    }

    @Override
    public void batchSave(List<RoleMenu> roleMenus) {
        this.saveBatch(roleMenus);
    }

    @Override
    public void deleteByRoleId(Long roleId) {
        QueryWrapper<RoleMenu> qw = new QueryWrapper<>();
        qw.eq("role_id",roleId);
        this.remove(qw);
    }

    @Override
    public void deleteByRoleIds(List<Long> roleIds) {
        QueryWrapper<RoleMenu> qw = new QueryWrapper<>();
        qw.in("role_id",roleIds);
        this.remove(qw);
    }
}
